﻿//-----------------------------------------------------------------
// All Rights Reserved , Copyright (C) 2012 , EricHu. 
//-----------------------------------------------------------------

using System;

namespace RDIFramework.ServiceAdapter
{
    using RDIFramework.IService;
    using RDIFramework.Utilities;

    /// <summary>
    /// RDIFrameworkService
    /// 
    /// 修改纪录
    /// 
    ///		2012.03.05 版本：1.0 EricHu 创建。
    ///		
    /// 版本：1.0
    ///
    /// <author>
    ///		<name>EricHu</name>
    ///		<date>2012.03.05</date>
    /// </author> 
    /// </summary>
    public class RDIFrameworkService : RDIFrameworkServiceFactory
    {
        private static readonly string servicePath = SystemInfo.Service;
        private static readonly string serviceFactoryClass = SystemInfo.ServiceFactory;
        
        public RDIFrameworkService()
        {
            serviceFactory = GetServiceFactory(servicePath, serviceFactoryClass);
        }

        private IServiceFactory serviceFactory = null;

        public void InitService()
        {
            serviceFactory.InitService();       
        }             

        private static RDIFrameworkService instance = null;
        private static object locker = new Object();

        /// <summary>
        /// 创建RDIFramework.NET平台服务
        /// </summary>
        public static RDIFrameworkService Instance 
        {
            get
            {
                if (instance == null)
                {
                    lock (locker)
                    {
                        if (instance == null)
                        {
                            instance = new RDIFrameworkService();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 登录服务
        /// </summary>
        public ILogOnService LogOnService
        {
            get
            {
                return serviceFactory.CreateLogOnService();
            }
        }

        /// <summary>
        /// 序列服务
        /// </summary>
        public ISequenceService SequenceService
        {
            get
            {
                return serviceFactory.CreateSequenceService();
            }
        }

        /// <summary>
        /// 用户服务
        /// </summary>
        public IUserService UserService
        {
            get
            {
                return serviceFactory.CreateUserService();
            }
        }

        /// <summary>
        /// 日志服务
        /// </summary>
        public ILogService LogService
        {
            get
            {
                return serviceFactory.CreateLogService();
            }
        }

        /// <summary>
        /// 异常服务
        /// </summary>
        public IExceptionService ExceptionService
        {
            get
            {
                return serviceFactory.CreateExceptionService();
            }
        }

        /// <summary>
        /// 权限项服务
        /// </summary>
        public IPermissionItemService PermissionItemService
        {
            get
            {
                return serviceFactory.CreatePermissionItemService();
            }
        }

        /// <summary>
        /// 组织机构服务
        /// </summary>
        public IOrganizeService OrganizeService
        {
            get
            {
                return serviceFactory.CreateOrganizeService();
            }
        }


        public IItemsService ItemsService
        {
            get
            {
                return serviceFactory.CreateItemsService();
            }
        }

        public IItemDetailsService ItemDetailsService
        {
            get
            {
                return serviceFactory.CreateItemDetailsService();
            }
        }
        
        /// <summary>
        /// 模块（菜单）服务
        /// </summary>
        public IModuleService ModuleService
        {
            get
            {
                return serviceFactory.CreateModuleService();
            }
        }

        public IStaffService StaffService
        {
            get
            {
                return serviceFactory.CreateStaffService();
            }
        }

        /// <summary>
        /// 角色服务
        /// </summary>
        public IRoleService RoleService
        {
            get
            {
                return serviceFactory.CreateRoleService();
            }
        }

        /// <summary>
        /// 文件服务
        /// </summary>
        public IFileService FileService
        {
            get
            {
                return serviceFactory.CreateFileService();
            }
        }

        /// <summary>
        /// 文件夹服务
        /// </summary>
        public IFolderService FolderService
        {
            get
            {
                return serviceFactory.CreateFolderService();
            }
        }

        //public IParameterService ParameterService
        //{
        //    get
        //    {
        //        return serviceFactory.CreateParameterService();
        //    }
        //}

        /// <summary>
        /// 权限服务
        /// </summary>
        public IPermissionService PermissionService
        {
            get
            {
                return serviceFactory.CreatePermissionService();
            }
        }

        public IDBProviderService RDIFrameworkDBProviderService
        {
            get
            {
                return serviceFactory.CreateRDIFrameworkDBProviderService();
            }
        }

        /// <summary>
        /// 表字段结构
        /// </summary>
        /// <returns>服务接口</returns>
        public ITableColumnsService TableColumnsService
        {
            get
            {
                return serviceFactory.CreateTableColumnsService();
            }
        }

        /// <summary>
        /// 数据库连接定义服务
        /// </summary>
        public IDbLinkDefineService DbLinkDefineService
        {
            get
            {
                return serviceFactory.CreateDbLinkDefineService();
            }
        }

        /// <summary>
        /// 平台插件服务
        /// </summary>
        public IPlatFormAddInService PlatFormAddInService
        {
            get
            {
                return serviceFactory.CreatePlatFormAddInService();
            }
        }
    }
}